﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


public class Soljd1
{
    public int[] Location(string move)
    {
        int[][] dir=new int[4][];
        dir[0] = new int[2];
        dir[1] = new int[2];
        dir[3] = new int[2];
        dir[2] = new int[2];

        dir[0][0] = 0;
        dir[0][1] = 1;

        dir[1][0] = -1;
        dir[1][1] = 0;

        dir[2][0] = 0;
        dir[2][1] = -1;

        dir[3][0] = 1;
        dir[3][1] = 0;
        //dir = [[0,1], [-1, 0], [0,-1],[1,0]];//上左下右



        int curdir = 0;//默认向上
        int[] pos =new int[2];
        pos[0] = 0;
        pos[1] = 0;
      

        for (int i = 0; i < move.Length; i++)
        {
            char c = move[i];

            //获取当前方向
            if (c == 'W')
            {
                pos[0] += dir[curdir][0];
                pos[1] += dir[curdir][1];
            }else if(c == 'A')
            {//左转

                curdir= (curdir+1)%4;
            }
            else if (c == 'D')
            {//左转
                if (curdir == 0)
                {
                    curdir = 3;
                }
                else
                {
                    curdir = (curdir - 1);
                }
                    
                
            }


        }

        return pos;

    } 
}
public class Programjd1
{
    public static void Mainjd1()
    {
        string line;
        while ((line = System.Console.ReadLine()) != null)
        { // 注意 while 处理多个 case
            //string[] tokens = line.Split();
            //System.Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1]));
       Soljd1 sol = new Soljd1();
        int[] res=   sol.Location(line);
            for (int i = 0; i < res.Length; i++)
            {
                Console.WriteLine(res[i]);
            }
           

        }
    }
}